<template>
	<view :style="$s.view_color+'background:'+pageitems.data[0].style.bgColor">

		<!-- #ifdef MP-WEIXIN -->
		<privacy-popup ref="privacyComponent" position="center" ></privacy-popup>
		<!-- #endif -->
		
		<indexDiy :pageitems="pageitems.data" :navback="false" @submit="submit"></indexDiy>
		
		<kefu-ball :scrollTop="20" :color="$s.theme" :list="kf_list" v-show="kf_status" bottom="80" right="16"></kefu-ball>
		
		<newcounponVue ref="newcoupon"></newcounponVue>
		
		<my-tabbar></my-tabbar>
	</view>
</template>

<script>
	import { mapState } from 'vuex'
	import indexDiy from './components/diy/index.vue'
	import newcounponVue from './components/newcounpon.vue'
	export default {
		components:{
			indexDiy,
			newcounponVue,
		},
		data() {
			return {
				nav_title:'首页',
                pageitems:[],
				kf_status:false,
				kf_list:[
					{
						icon:{name:'phone',customprefix:'uicon'},
						name: '客服',
						url: '',
						tel: '',
						type:'tel'
					},
					{
						icon:{name:'server-fill',customprefix:'uicon'},
						name: '在线客服',
						type:'contact',
					}
				],
			}
		},
		async onLoad(option){
			await this.$configResolve
			this.nav_title=this.$config.base.company
			
			//判断是否设置客服电话
			let service_phone=this.$config.base.service_phone
			if(service_phone){
				this.kf_status=true
				this.kf_list[0].tel=service_phone
			}
		},
		onShow(){
			this.initData()
		},
		computed:{
			...mapState({
			})
		},
		watch:{
			
		},
		methods: {
			initData(){
				this.$u.api.homePage().then(res=>{
					this.pageitems=res.data.page;
					if(res.data.new_coupon==1){	
						this.$refs.newcoupon.open()
					}
				})
			},
			
			//提交预定数据
			submit(){
				this.$c.a('car/list/index')
			},
		}
	}
</script>

<style lang="scss">
</style>
